<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <script>
    	var payChannel="1";
    </script>
    <meta charset="UTF-8">
    <title>我要提现</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
	<c:set var="ctx" value="${pageContext.request.contextPath}" />
    <link rel="stylesheet" href="${ctx}/assets/css/amazeui.min.css">
    <link rel="stylesheet" href="${ctx}/assets/css/style.css?v=2.3">
    <link rel="stylesheet" href="${ctx}/assets/css/index.css?v=2.3">
    <script src="${ctx}/assets/js/myAlert.js"></script>
</head>
<body class="bg-white">
<header data-am-widget="header" class="am-header am-header-default am-header-fixed am-border-bottom">
    <div class="am-header-left am-header-nav">
        <a onclick="history.go(-1)"> <i class="icon_8"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        我要提现
    </h1>
    <div  class="am-header-right am-header-nav am-text-right font-14" >
       <a href="${ctx}/gotoTixianjilu"> 提现记录</a>
    </div>
</header>
<section class="am-padding-bottom-sm" id="amz-main" data-tag="css-nav">

    <div class="am-padding-left-sm am-padding-right-sm am-margin-top-sm">
        <div class="box font-color-17">
            <div class="width-40px"><div class="icon_70"></div></div>
            <div class="box-1 padding-top-3px ">
                当前余额：&yen;${yuer}
            </div>
        </div>

        <div class="am-margin-top-sm am-margin-bottom-xs input-div-3" >
            <input type="money" id="money" class="input-3 font-14" placeholder="请输入提现金额">
        </div>

        <!--付款方式-->
        <div class="bg-white pay-type  ">
            <div data-node="pay_type"  class="am-list-news am-list-news-default  am-margin-bottom-xs font-color-13">

                <div class="am-list-news-bd ">
                    <ul class="am-list">

                        <li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left padding-li-2 type">

                            <div class=" am-u-sm-11 am-list-main">
                                <div class="box">
                                    <div class="width-40px ">
                                        <img class="img-30" src="${ctx}/assets/images/icon/public/icon_10.png"/>
                                    </div>
                                    <div class="box-1">
                                        <h3 class="am-list-item-hd padding-top-3">
                                            微信账户
                                        </h3>
                                    </div>
                                </div>

                            </div>
                            <div class=" am-u-sm-1 padding-0">
                                <div class="icon-gouxuan cur"></div>
                            </div>
                        </li>
                        <li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left padding-li-2 type">
                            <div class=" am-u-sm-11 am-list-main">
                                <div class="box">
                                    <div class="width-40px ">
                                        <img class="img-30" src="${ctx}/assets/images/icon/public/icon_11.png"/>
                                    </div>
                                    <div class="box-1">
                                        <h3 class="am-list-item-hd padding-top-3">
                                            银行卡
                                        </h3>
                                    </div>
                                </div>

                            </div>
                            <div class=" am-u-sm-1 padding-0">
                                <div class="icon-gouxuan "></div>
                            </div>
                        </li>

                    </ul>
                </div>
            </div>






        </div>


        <div class=" am-margin-bottom-xs input-div-3" >
            <input type="text" class="input-3 font-14" id="bankName" placeholder="请输入银行名称">
        </div>

        <div class="am-margin-top-sm am-margin-bottom-xs input-div-3" >
            <input type="text" class="input-3 font-14" id="account" placeholder="请输入您的账号">
        </div>

    </div>


    <div class="box font-color-13  am-padding-left-sm am-padding-right-sm am-margin-top-sm">
        <div class="width-40px"><div class="icon_69"></div></div>
        <div class="box-1 padding-top-3px font-color-13">
            绑定手机：${counseTel}
        </div>
    </div>

    <div class="am-g">
        <div class="am-u-sm-7 padding-right-0"> <div class="am-margin-top-sm am-margin-bottom-xs input-div-3" >
            <input type="number" class="input-3 font-14" id="code" placeholder="请输入收到的验证码">
        </div></div>
        <div class="am-u-sm-5">
            <div class="btn-20" onclick="createCode()">获取验证码</div>
        </div>
    </div>

    <div class="am-container am-margin-top-sm">
        <div class="btn-4 word-space-2 padding-left-0" onclick="tijiao()">提交</div>
    </div>

</section>
<script src="${ctx}/assets/js/jquery.min.js"></script>
<script src="${ctx}/assets/js/amazeui.min.js"></script>
<script>
var wait=60;  
function createCode(){
	if(wait==60){
		var baseResponse=$.ajax({url:"${ctx}/sendAuthCode?telphone=${counseTel}",async:false});
	  	var sendAuthCode=JSON.parse(baseResponse.responseText);
	   	if(sendAuthCode.resultCode=="0"){
	   	}else{
	   		myAlert(sendAuthCode.resultDesc);
	   	}
	}
	
	if(wait == 0) {  
       $(".btn-20").attr("onclick","createCode()");
        $(".btn-20").text("获取验证码");  
        wait = 60;  
    }else {  
        $(".btn-20").attr("onclick",null);
        $(".btn-20").text("重新发送(" + wait + ")");  
        wait--;  
        setTimeout(function() {  
            createCode(); 
        },  
        1000);  
    } 
}
</script>
<script>
	function tijiao(){
		var bankName=$("#bankName").val();
		var account=$("#account").val();
		var money=$("#money").val();
		var code=$("#code").val();
		if(payChannel=="0"){
			if(bankName==""){
				myAlert("请输入银行卡名称");
				return false;
			}
			if(account==""){
				myAlert("请输入银行卡号");
				return false;
			}
			
		}else{
			account='${counseTel}';
		}
		if(money==""){
			myAlert("请输入提现金额");
			return false;
		}
		if(code==""){
			myAlert("请输入短信验证码");
			return false;
		}
		
		var tijianStr=$.ajax({url:"${ctx}/gotoTixian?bankName="+bankName+"&code="+code+"&money="+money+"&account="+account+"&payChannel="+payChannel,async:false});
        var jixianJson=JSON.parse(tijianStr.responseText);
        if(jixianJson.resultCode=="0"){
        		alert("提交申请成功，请等待核查");
			   location.href="${ctx}/gotoTixianjilu"; 
        }else{
        	alert(jixianJson.resultDesc);
        }
		
	}

    $("[data-node='pay_type']").find(" li.type").click(function () {
        $("[data-node='pay_type']").find(" li.type .icon-gouxuan").removeClass("cur");
        $(this).find(".icon-gouxuan").addClass("cur");
        var content=$(this).text();
        if(content.indexOf("银行")>0){
        	payChannel="0";
        }else if(content.indexOf("微信")>0){
        	payChannel="1";
        }
    });

</script>
</body>
</html>